package com.iflytek.universitymanagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iflytek.universitymanagement.domain.StudentGrowth;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentGrowthMapper extends BaseMapper<StudentGrowth> {

//    // 查询所有学生成长数据及学生姓名
//    @Select("SELECT sg.growth_id, sg.student_id, sg.moral_education, sg.intellectual_education, " +
//            "sg.physical_education, sg.aesthetic_education, sg.labor_education, s.name AS student_name " +
//            "FROM student_growth sg " +
//            "JOIN student s ON sg.student_id = s.student_id")
//    List<StudentGrowth> getAllStudentGrowthsWithNames();

    // 分页查询所有学生成长数据及学生姓名
    @Select("SELECT sg.growth_id, sg.student_id, sg.moral_education, sg.intellectual_education, " +
            "sg.physical_education, sg.aesthetic_education, sg.labor_education, s.name AS student_name " +
            "FROM student_growth sg " +
            "JOIN student s ON sg.student_id = s.student_id")
    Page<StudentGrowth> getAllStudentGrowthsWithNames(Page<StudentGrowth> page);


    // 根据学生 ID 查询成长数据及学生姓名
    @Select("SELECT sg.growth_id, sg.student_id, sg.moral_education, sg.intellectual_education, " +
            "sg.physical_education, sg.aesthetic_education, sg.labor_education, s.name AS student_name " +
            "FROM student_growth sg " +
            "LEFT JOIN student s ON sg.student_id = s.student_id " +
            "WHERE sg.student_id = #{studentId}")
    List<StudentGrowth> getStudentGrowthsWithNames(Integer studentId);
}
